package uni.UNIBEE7B8D.view.Study.ZhiboContent;


import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import uni.UNIBEE7B8D.Adapter.RecycClickOnListener;
import uni.UNIBEE7B8D.Adapter.study.StudentAdaPter;
import uni.UNIBEE7B8D.Adapter.study.ZhiboRecycAdapter;
import uni.UNIBEE7B8D.Enty.CommonClass;
import uni.UNIBEE7B8D.R;


/**
 * A simple {@link Fragment} subclass.
 */
public class StudentsFragment extends Fragment {

    @BindView(R.id.zhiboList)
    RecyclerView zhiboList;
    private String[] titles = {"张三", "李四", "王五", "赵六","张三", "李四", "王五", "赵六",
            "张三", "李四", "王五", "赵六","张三", "李四", "王五", "赵六",};
    private int[] zhibo_image = {R.drawable.img_touxiang,R.drawable.img_touxiang,R.drawable.img_touxiang,R.drawable.img_touxiang,
            R.drawable.img_touxiang,R.drawable.img_touxiang,R.drawable.img_touxiang,R.drawable.img_touxiang,
            R.drawable.img_touxiang,R.drawable.img_touxiang,R.drawable.img_touxiang,R.drawable.img_touxiang,
            R.drawable.img_touxiang,R.drawable.img_touxiang,R.drawable.img_touxiang,R.drawable.img_touxiang};

    public StudentsFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_students, container, false);
        ButterKnife.bind(this, view);//注意
        return view;
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        //--------直播-----------------
        List<CommonClass> zhiboClasses = new ArrayList<>();
        for (int i = 0; i < titles.length; i++) {
            CommonClass commonClass1 = new CommonClass();
            commonClass1.setTitle(titles[i]);
            commonClass1.setArea("华南地区");
            commonClass1.setDra_iamge(zhibo_image[i]);
            zhiboClasses.add(commonClass1);
        }
        // 设置布局管理器
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(RecyclerView.VERTICAL);


//        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false) {
//            @Override
//            public boolean canScrollVertically() {
//                return false;
//            }
//        };


        zhiboList.setLayoutManager(linearLayoutManager);

        StudentAdaPter zhiboRecycAdapter = new StudentAdaPter(zhiboClasses, getActivity());
        zhiboList.setAdapter(zhiboRecycAdapter);
//        zhiboRecycAdapter.setRecycClickOnListener(new RecycClickOnListener() {
//            @Override
//            public void onItemClick(CommonClass commonClass) {
//
//            }
//        });
    }

}
